home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Patches 1998 April / IRIX 6.4 Recommended-Required Patches April 1998.img / dist / 6.4_OCTANE / patchSG0002538.idb / usr / lib / desktop / togglexhost.z / togglexhost
Text File  |  1997-12-08  |  3KB  |  86 lines

  1. #!/bin/bsh
  2.  
  3. # Toggles xhost on or off (does "xhost +" or "xhost -")
  4. # and posts an xconfirm as feedback after each operation.    
  5. # The xconfirm messages are in /usr/share/misc/sessionwarnings.
  6. #
  7. # Takes one argument: "+" or "-" indicating which operation 
  8. # to perform.
  9. #
  10. # Author: Rebecca Underwood
  11. # Initial revision: 22 August 1996 for IRIX 6.3
  12. #
  13.  
  14. if [ $# -ne 1 ]; then
  15.     exit 1
  16. fi
  17.  
  18. if [ "$1" != "+" -a "$1" != "-" ]; then
  19.     exit 1
  20. fi
  21.  
  22. # Note: If Xsession.dt changes where it gets its messages from,
  23. # then you should change these next lines here too to keep
  24. # all files in the same place.  The next session is copied from
  25. # Xsession.dt.
  26.  
  27. confirmdirectory=/usr/share/misc/sessionwarnings
  28.  
  29. # Set the user's language.    Try to get correct locale in this
  30. # order per Erik: First try desktopenv, second try $HOME/.lang,
  31. # last try /etc/default/login, and as a last resort use C.
  32. #
  33. # 1) If $LANG is set, then Xsession.dt or ipanel has most likely 
  34. # put it in the environment.
  35. if [ "$LANG" = "" ]; then
  36.     # 2) If LANG isn't set, try $HOME/.lang.
  37.     lang=$HOME/.lang
  38.     if [ -r $lang -a -f $lang ]
  39.     then
  40.         _lang=`cat $lang`
  41.         lconfirmdirectory=$confirmdirectory/$_lang
  42.     else
  43.         # 3) If no $HOME/.lang, try system default.
  44.         deflogin=/etc/default/login
  45.         if [ -r $deflogin -a -f $deflogin ]
  46.         then
  47.             _lang=`grep LANG= $deflogin|egrep -v \#|sed 's/LANG=//'` 
  48.             lconfirmdirectory=$confirmdirectory/$_lang    
  49.         else
  50.             # 4) Last resort.
  51.             lconfirmdirectory=$confirmdirectory/C
  52.         fi
  53.     fi
  54. else
  55.     lconfirmdirectory=$confirmdirectory/$LANG
  56. fi
  57.  
  58.  
  59. # If $confirmdirectory/C is missing, then this can fail
  60. # to post a message. It seems unlikely that it will
  61. # be missing, though, because C is the default locale.
  62. # (The alternative would be to hardcode a default message
  63. # right into this script.)
  64. #
  65. if [ "$1" = "+" ]; then
  66.     /usr/bin/X11/xhost + > /dev/null
  67.     if [ -r $lconfirmdirectory/xhost.on.msg ]; then
  68.         xconfirm -b "`gettxt uxsgidesktop:736 'Continue'`" \
  69.         -file $lconfirmdirectory/xhost.on.msg -c > /dev/null
  70.     else 
  71.         xconfirm -b "`gettxt uxsgidesktop:736 'Continue'`" \
  72.         -file $confirmdirectory/C/xhost.on.msg -c > /dev/null
  73.     fi
  74. else
  75.     /usr/bin/X11/xhost - > /dev/null
  76.     if [ -r $lconfirmdirectory/xhost.off.msg ]; then
  77.         xconfirm -b "`gettxt uxsgidesktop:736 'Continue'`" \
  78.         -file $lconfirmdirectory/xhost.off.msg -c > /dev/null
  79.     else
  80.         xconfirm -b "`gettxt uxsgidesktop:736 'Continue'`" \
  81.         -file $confirmdirectory/C/xhost.off.msg -c > /dev/null
  82.     fi
  83. fi
  84.  
  85. exit 0
  86.